#include "kicktogoal.h"


string Kicktogoal:: command(Parser parser) 
{
   //output.str("");
    //If es del otro campo, a la goal_l
    //int kickangle= parser.theirgoal[1];
    int kickangle;
    int kickforce= 100;

    if(parser.field=="left")
    {
        if(parser.flag_g_r_b[0] < parser.flag_g_r_t[0]) 
           kickangle = parser.goal_r[1] - parser.flag_g_r_b[0]; 
        else
           kickangle = parser.goal_r[1] - parser.flag_g_r_t[0];   
        /*cout<<"Angulo palo arriba: "<< parser.flag_g_r_b[0]<<endl;
        cout<<"Angulo palo abajo: "<< parser.flag_g_r_t[0]<<endl;
        cout<<"Angulo porteria: " <<parser.goal_r[1]<<endl;
        cout<<"Kick Angle: " <<kickangle<<endl;*/
    }
    else if(parser.field=="right")
    {
        if(parser.flag_g_l_b[0] < parser.flag_g_l_t[0]) 
           kickangle = parser.goal_l[1] - parser.flag_g_l_b[0]; 
        else
           kickangle = parser.goal_l[1] - parser.flag_g_l_t[0];   
    }
    output<<kick(kickforce,kickangle);
		    parser.init(); 
    return output.str();
}


